package com.android.Translator.View.utils;

import com.android.Translator.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.Gravity;
import android.widget.TextView;

public class ViewUtils {
	
	public static int TIME_10_SECONDS = 1;
	public static int TIME_20_SECONDS = 2;
	public static int TIME_30_SECONDS = 3;
	public static int ACTION_EXIT 	  = 0;
	public static int ACTION_LAUNCH   = 1;
	public static int ACTION_INFORM	  = 2;
	public static int ACTION_FINISH	  = 3;
	
	
	public static void ShowAlertDialog(final Activity activity, final Activity actToStart, 
			final int ActionID ,String title, String message)
	{
		Builder b = new AlertDialog.Builder(activity, R.style.Theme_UserAlertDialog);
		b.setPositiveButton("OK", new DialogInterface.OnClickListener() {

			public void onClick(DialogInterface dialog, int which) {
				if (ActionID == ACTION_EXIT)
					activity.finish();
				else if(ActionID == ACTION_LAUNCH)
				{
					Intent i = new Intent(activity, actToStart.getClass());
					activity.startActivity(i);
				}
			}
		});
		if(ActionID != ACTION_INFORM && ActionID != ACTION_FINISH)
		{
			b.setNegativeButton("NO", new DialogInterface.OnClickListener() {
	
				public void onClick(DialogInterface dialog, int which) {
					dialog.dismiss();
				}
			});
		}
		b.setTitle(title);
		b.setMessage(message);
		b.setIcon(R.drawable.warning);
		AlertDialog dialog = b.show();
		TextView messageText = (TextView)dialog.findViewById(android.R.id.message);
		messageText.setGravity(Gravity.CENTER);
		dialog.show();
	}


	public static void ShowProcessCircle(Activity m_activity, ProgressDialog progressBar) {
		// TODO Auto-generated method stub
		
	     progressBar.setCancelable(true);
	     progressBar.setProgressStyle(ProgressDialog.STYLE_SPINNER);            
	     progressBar.show();
	}


	public static void dismissProcessCircle(ProgressDialog progressBar) {
		// TODO Auto-generated method stub
		progressBar.dismiss();
	}
}
